// Information Carousel View
//
// MDM 10.06.2012

Ext.define('Sencha.view.SoundsOfIwaidjaInfoView', {
    extend: 'Ext.Carousel',
    xtype: 'soundsofiwaidjainfoview',
    config: {
        title: 'Information',
        fullscreen: true,
        defaults: {
            styleHtmlContent: true
        },
        cls: 'infocarousel',
           
        items: [
            {
                scrollable: {
                    direction: 'vertical',
                    directionLock: true
                },
                html : "<div class=infosection><div class=header><p>The sounds of Iwaidja</p></div><p>The idea of this section is to give you a little time to listen closely to the sounds of Iwaidja before plunging into learning to speak the language.</p><div class=infotitle><p>Vowels</p></div><p>Iwaidja has 20 consonants, but only three vowels. You may not find the vowels too difficult. For a start, there are less of them than in English. What’s more, they should be fairly familiar to most of you, because they’re the basic vowels in the languages of the world. They’re very similar to some English vowels and are easy to pronounce. Touch the words in the 'Iwaidja' column in the table below to hear what they sound like. You should quickly get the hang of it. Just remember always to pronounce an ‘a’ as in ‘car’, an ‘i’ as in ‘bin’, or sometimes as in ‘bean’ (we’ll let you know when) and a ‘u’ as in ‘full’ or ‘wool’. That’s all!</p><table cellspacing=\'0\' cellpadding=\'0\'><tbody><tr><td valign=\'bottom\' width=\'33%\'><p><b>Vowel</b></p></td><td valign=\'bottom\'><p><b>Iwaidja Example</b></p></td><td valign=\'bottom\'><p><b>English Rhyme</b></p></td></tr><tr><td valign=\'middle\'><p><b>a</b> (ah)</p></td><td valign=\'middle\'><div class=ma_sound>m<b>a</b></div><div>'ok'</div></td><td valign=\'middle\'><p>c<b>a</b>r</p></td></tr><tr><td valign=\'middle\'><p><b>i</b> (ee)</p></td><td valign=\'middle\'><div class=kindi_sound>k<b>i</b>nd<b>i</b></a></div><div>'how?'</div></td><td valign=\'middle\'><p>w<b>i</b>ndy</p></td></tr><tr><td valign=\'middle\'><p><b>u</b> (oo)</p></td><td valign=\'middle\'><div class=ma_wak>w<b>u</b>k</div><div>'ant'</div></td><td valign=\'middle\'><p>book</p></td></tr></tbody></table><br><br></div>",
                listeners : [
                    {
                        element: 'element',
                        delegate: 'div.ma_sound',
                        event: 'tap',
                        fn: function(event, el) {
                             var audioURL = Sencha.app.getPersistentFileStoreVar() + "/assets/sounds/ma.m4a"
                             this.getParent().playAudio(audioURL);
                        }
                    },
                    {
                        element: 'element',
                        delegate: 'div.kindi_sound',
                        event: 'tap',
                        fn: function() {
                             var audioURL = Sencha.app.getPersistentFileStoreVar() + "/assets/sounds/kindi.m4a"
                             this.getParent().playAudio(audioURL);
                        }
                    },
                    {
                        element: 'element',
                        delegate: 'div.ma_wak',
                        event: 'tap',
                        fn: function() {
                             var audioURL = Sencha.app.getPersistentFileStoreVar() + "/assets/sounds/wak.m4a"
                             this.getParent().playAudio(audioURL);
                        }
                    } 
                ] 
            },
            {
                html : "<div class=infosection><div class=infotitle><p>Consonants</p></div><p>Of the 20 Iwaidja consonants, some are represented by a single letter, such as \‘k\’, and others by two letters, such as \‘ng\’. Let’s start with the consonants represented by a single letter and which sound pretty much the same as in English.</p></div>"
            }
        ]
    },
           
    playAudio: function(audioURL) {
           console.log('play audio from parent fn.');
           console.log('audioURL = ' + audioURL);
           var my_media = new Media(
                                    audioURL,
                                    // success callback
                                    function() {
                                    console.log("playAudio():Audio Success");
                                    },
                                    // error callback
                                    function(err) {
                                    console.log("playAudio():Audio Error: "+err);
                                    navigator.notification.alert(msg, null, 'Capture error');
                                    }
                                    );
           
           //Sencha.app.mediaPtr=my_media;
           
           my_media.play();
           //my_media.release();
    }
    
});